package com.tanchengjin.admin.service.impl;

import com.tanchengjin.admin.modules.cms.mapper.ArticleCommentMapper;
import com.tanchengjin.admin.modules.cms.pojo.ArticleComment;
import com.tanchengjin.admin.service.ArticleCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * create by  article_comment ServiceImpl
 *
 * @author TanChengjin
 * @since v1.0.0
 * @version v1.0.0
 */
@Service("articleCommentService")
public class ArticleCommentServiceImpl implements ArticleCommentService {

    @Autowired
    private ArticleCommentMapper articleCommentMapper;

    public ArticleComment findOneById(int id)
    {
        ArticleComment articleComment = articleCommentMapper.selectByPrimaryKey(id);
        return articleComment;
    }

    public int deleteById(int id)
    {
        int i = articleCommentMapper.deleteByPrimaryKey(id);
        return i;

    }

    public int create(ArticleComment articleComment)
    {
        int i = articleCommentMapper.insertSelective(articleComment);
        return i;
    }

    public int updateById(ArticleComment articleComment, int id)
    {
        articleComment.setId(id);
        int i = articleCommentMapper.updateByPrimaryKeySelective(articleComment);
        return i;
    }

    public List<ArticleComment> getAll()
    {
        List<ArticleComment> articleCommentList = articleCommentMapper.getAll();
        return articleCommentList;
    }

    public List<ArticleComment> getAllByCondition(ArticleComment articleComment)
    {
        List<ArticleComment> articleCommentList = articleCommentMapper.getAllByCondition(articleComment);
        return articleCommentList;
    }

    public int batchDelete(int[] ids)
    {
        int i = 0;
        for(int id : ids)
        {
            i+= articleCommentMapper.deleteByPrimaryKey(id);
        }
        return i;
    }

    public int count()
    {
        return articleCommentMapper.count();
    }
}